// Mmanagement/adfillInforM/adfillInforM.js
const app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    inpvalue:'请选择',
    hidden:false,
    inpclicknum:0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this;
    app.comrequest('https://ipass.cc/myapi/Mmanagement/MUloginxg.php', {num:13}).then(res=>{
      that.setData({
        xlselects:res
      })
    })
  },
  inpclick(){
    var inpclicknum=this.data.inpclicknum
    inpclicknum=inpclicknum+1
    this.setData({
        inpclicknum
    })
    if(inpclicknum%2==0){
        this.setData({
            hidden:false,
        })
    }else{
        this.setData({
            hidden:true,
        })
    }
  },
  xlclick(e){
    var shopname=e.target.dataset.shopname;
    var shopnumber=e.target.dataset.shopnumber;
    this.setData({
      inpvalue:shopnumber,
      hidden:false,
      inpclicknum:this.data.inpclicknum+1
    })
  },
  formSubmit(e){
    var storeaddress=e.detail.value.storeaddress;
    var storearea=e.detail.value.storearea;
    var landlord=e.detail.value.landlord;
    var ltelephone=e.detail.value.ltelephone;
    var remarks=e.detail.value.remarks;
    var shopnumber=e.detail.value.selectvalue;
    if(storeaddress!=""&&storearea!=""&&landlord!=""&&ltelephone!=""&&remarks!=""){
      if(shopnumber=="请选择"){
        wx.showToast({
          title: '请选择要修改的店铺编号',
          icon:'none'
        })
      }else{
        // 发送请求保存到数据库
        app.comrequest('https://ipass.cc/myapi/Mmanagement/MUloginxg.php', {num:14,storeaddress,storearea,landlord,ltelephone,remarks,shopnumber}).then(res=>{
          if(res=="修改成功"){
            wx.showToast({
              title: "添加成功",
              icon:'none'
            })
          }
        })
      }
    }else{
      wx.showToast({
        title: '输入框不能为空',
        icon:'none'
      })
    }
  }
})